package tk1.uebung3.model;

import java.util.HashMap;

import javax.jws.WebMethod;

public class ShoppingCart {
	
	private final String id;
	
	private HashMap<ProductType,Integer> productsToAmounts;
	
	public ShoppingCart(){
		this.id = String.valueOf((int)(Math.random()*10000000));
		productsToAmounts = new HashMap<ProductType,Integer>();
	}
	
	public String getId() {
		return id;
	}
	
	public void addProduct(ProductType producType, int amount){
		Integer newAmount;
		if(productsToAmounts.containsKey(producType)){
			int amountBefore = productsToAmounts.get(producType).intValue();
			newAmount = Integer.valueOf(amountBefore + amount);
		}
		else{
			newAmount = Integer.valueOf(amount);
		}
		this.productsToAmounts.put(producType, newAmount);
	}

}
